var xtPostWinAdd;
var xtPostFormAdd;
function addXtPost(xt_departinfo_id,xt_post_id,xt_departinfo_name){
	initXtPostFormAdd();
	//显示值
	Ext.getCmp('xt_departinfo_name').setValue(xt_departinfo_name);
	//提交值
	Ext.getCmp('did').setValue(xt_departinfo_id);
	//提交值
	Ext.getCmp('xt_post_parentId').setValue(xt_post_id);
	//显示值
	Ext.getCmp('pid').setValue(xt_post_id);
	xtPostWinAdd = Ext.create('Ext.Window',{
		layout:'fit',
		width:800,
		height:400,
		maximizable:true,
		minimizable:true,
		animateTarget:document.body,
		plain:true,
		modal:true,
		listeners:{
			minimize:function(win,opts){
				if(!win.collapse()){
					win.collapse();
				}else{
					win.expand();
				}
			}
		},
		title:'添加岗位信息',
		items:xtPostFormAdd,
		buttons:[{
			text:'保存',
			itemId:'save',
			handler:function(button){
				submitForm(xtPostFormAdd,'../xtPostController/addXtPost',grid,xtPostWinAdd,false,true,true);
			}
		},{
			text:'关闭',
			itemId:'close',
			handler:function(button){
				button.up('window').close();
			}
		}]
	});
	xtPostWinAdd.show();
}
function initXtPostFormAdd(){
	xtPostFormAdd = Ext.create('Ext.FormPanel',{
		xtype:'form',
		labelWidth:50,
		waitMsgTarget:true,
		defaultType:'textfield',
		autoScroll:true,
		fieldDefaults:{
	        labelWidth:70,
	        labelAlign:"left",
	        flex:1,
	        margin:'4 5 4 5'
	    },
	    /**新方法使用开始**/  
        scrollable:true,  
        scrollable:'x',
        scrollable:'y',
        /**新方法使用结束**/ 
		items:[
		{
			fieldLabel:'部门',
			xtype:'textfield',
			hidden:true,
			name:'xt_departinfo_id',
			id:'did',
			allowBlank:false,
			maxLength:32,
			anchor:'40%'
		},
		{
			fieldLabel:'上级岗位',
			xtype:'textfield',
			hidden:true,
			name:'xt_post_parentId',
			id:'xt_post_parentId',
			allowBlank:false,
			maxLength:32,
			anchor:'40%'
		},
		{
			fieldLabel:'部&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;门',
			xtype:'textfield',
			id:'xt_departinfo_name',
			allowBlank:false,
			disabled:true,
			maxLength:32,
			anchor:'40%'
		},
		{
			fieldLabel:'上级岗位',
			xtype:'treepicker',
			displayField:'text',
			anchor:'40%',
			hiddenName:'xt_post_parentId',
			name:'xt_post_parentId',
			minPickerHeight:200,
			maxHeight:200,
			id:'pid',
			editable:false,
			disabled:true,
			rootVisible:false, 
			store:Ext.create('Ext.data.TreeStore',{
				fields:['id','text'],
				root:{
					text:'一级岗位',
					id:'0',
					expanded:true
				},
				proxy:{
					type:'ajax',
					url:'../xtPostController/getXtPostTree',
					reader:{
						type:'json'
					}
				}
			})
		},
		{
			fieldLabel:'岗位名称',
			xtype:'textfield',
			name:'xt_post_name',
			allowBlank:false,
			maxLength:50,
			anchor:'40%'
		},
		{
			fieldLabel:'岗位描述',
			xtype:'textareafield',
			name:'xt_post_desc',
			maxLength:200,
			anchor:'100%'
		},
		{
			fieldLabel:'最大人数',
			xtype:'numberfield',
			name:'xt_post_maxNum',
			anchor:'40%'
		},
		{
			fieldLabel:'岗位级别',
			xtype:'numberfield',
			name:'xt_post_grade',
			anchor:'40%'
		}
		]
	});
}
